package HomeService

import (
	"context"
	"gdshop-back-end-go/client-api/app/request/HomeReq"
	"gdshop-back-end-go/client-api/app/response/HomeResp"
	toolsDb "gdshop-back-end-go/common/db"
	"gdshop-back-end-go/common/response"
)

func Slides(ctx context.Context, parames *HomeReq.Slides) *response.JsonResponse {
	listDb := toolsDb.GetUnSafaTableAddDeleteWhere(ctx, "slides").Order("id DESC").Order("sort DESC")
	if parames.Cid > 0 {
		listDb.Where("category_id=?", parames.Cid)
	}
	var slidesList []*HomeResp.Slides
	err := listDb.Structs(&slidesList)
	if err != nil {
		return response.FailByRequestMessage(nil, err.Error())
	}

	return response.SuccessByRequestMessageData(nil, "成功", slidesList)
}
